#ifndef _ICECODE_UTILS_HPP
#define _ICECODE_UTILS_HPP

#include <string>
#include <vector>
#include "passwd.hpp"
#include "debug.hpp"
#include "args.hpp"

namespace icecode {
  namespace utils {

    //Path utils

    /*
      DESCRIPTION:
       Normalizes the path. Resolves home directory, . and .., CWD relative paths. Does not check for path existence.

      ARGUMENTS:
       path: The path to be normalized.

      RETURNS:
       The absolute, normalized path.

      THROWS:
       std::out_of_range("User name does not exist.")
     */
    std::string normalizePath(std::string path);


    //String utils

    /*
      DESCRIPTION:
       Splits a string into substrings delimited by any (but not combined) of the passed tokens.

      ARGUMENTS:
       str: The string to split.
       tokens: The token string, a list of chars used to determine the substrings boundaries.
       removeEmpty: If true, doesn't add the empty substrings to the result vector.B
     */
    std::vector<std::string> splitString(std::string str, std::string tokens = "\n", bool removeEmpty = true);

    /*
      DESCRIPTION:
       Joins a vector of strings, separating the string parts with the a string.

      ARGUMENTS:
       s: The vector of strings to join.
       token: The token string.
     */
    std::string joinString(std::vector<std::string> s, std::string token = "");

    std::string trimLeft(std::string src, std::string trim_chars = "\n \t");
    std::string trimRight(std::string src, std::string trim_chars = "\n \t");
    std::string trim(std::string src, std::string trim_chars = "\n \t");
  }
}

#endif //_ICECODE_UTILS_HPP
